import type { ITask } from '@/api/task'
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getTask } from '@/api/task'

export const useTaskStore = defineStore(
  'task',
  () => {
    const taskLists = ref<ITask[]>([])

    const fetchTaskList = async () => {
      getTask().then((res) => {
        taskLists.value = res
      })
    }

    return {
      taskLists,
      fetchTaskList,
    }
  },
  {
    persist: true,
  },
)
